package com.tledu.mvc02.controller;

import com.tledu.mvc02.model.User;
import com.tledu.mvc02.service.UserService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * mvc整合mybatis实现增删改查
 *
 * @author Antg
 * @date 2021/8/12  1:23
 */
@RestController
@RequestMapping("/user")
@AllArgsConstructor
public class UserController{
    private final UserService userService;

    @GetMapping("/findAll")
    public List<User> findAll() {
        return userService.findAll();
    }

    @PostMapping("/add")
    public int add(User user) {
        return userService.add(user);
    }

    @PostMapping("/edit")
    public int edit(User user) {
        return userService.edit(user);
    }

    @DeleteMapping("/del")
    public int del(int id) {
        return userService.del(id);
    }
}
